package edu.hrbu.spring.service.impl;

import edu.hrbu.spring.mapper.DeptMapper;
import edu.hrbu.spring.pojo.Dept;
import edu.hrbu.spring.pojo.User;
import edu.hrbu.spring.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 徐登宇
 */
@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    DeptMapper deptMapper;

    @Override
    public List<Dept> getAll() {
        return deptMapper.selectList();
    }

    @Override
    public Dept getById(Integer id) {
        return deptMapper.selectById(id);
    }

    @Override
    public boolean removeById(Integer id) {
        return deptMapper.delById(id);
    }

    @Override
    public boolean save(Dept dept) {
        return deptMapper.insert(dept);
    }

    @Override
    public List<User> getOwnUserNameByDeptId(Integer id) {
        return deptMapper.getOwnUserNameByDeptId(id);
    }

    @Override
    public List<User> getUserListByDeptId(Integer deptId) {
        return deptMapper.getUserListByDeptId(deptId);
    }
}
